﻿$(document).ready(function () {
    $(".on2").click(function () {
        if ($(this).hasClass("off")) {
            $(this).removeClass("off");
            $(this).removeClass("fa-rotate-180");
            $(this).removeClass("w3-text-red");
            $(this).addClass("w3-text-teal");
        }
        else {
            $(this).addClass("w3-text-red");
            $(this).removeClass("w3-text-teal");
            $(this).addClass("fa-rotate-180");
            $(this).addClass("off");
        }

        var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
            }
        };
        xhttp.open("GET", "../ajax/asp/user/active.aspx?id=" + id, true);
        xhttp.send();
    });

    $(".user_del").on("click", function () {
        document.getElementById("del_id").innerHTML = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
    });
    $("#btn_user_del_yes").on("click", function () {
        var id = document.getElementById("del_id").innerHTML;

        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("xoanhanvien").style.display = 'none';
                $("#user" + id).remove();

            }
        };
        xhttp.open("GET", "../ajax/asp/user/del_user.aspx?id=" + id, true);
        xhttp.send();
    });

    $("#find_by_level").on("change", function () {

        var id = document.getElementById("find_by_level").value;
        if (id == "") {
            document.getElementById("btn_level_edit").style.display = "none";
            document.getElementById("add_member").style.display = "none";
        }
        else {
            document.getElementById("btn_level_edit").style.display = "inline-block";
            document.getElementById("add_member").style.display = "inline-block";
        }
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("user_show").innerHTML = xhttp.responseText;
                $(".on2").click(function () {
                    if ($(this).hasClass("off")) {
                        $(this).removeClass("off");
                        $(this).removeClass("fa-rotate-180");
                        $(this).removeClass("w3-text-red");
                        $(this).addClass("w3-text-teal");
                    }
                    else {
                        $(this).addClass("w3-text-red");
                        $(this).removeClass("w3-text-teal");
                        $(this).addClass("fa-rotate-180");
                        $(this).addClass("off");
                    }

                    var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 || xhttp.status == 200) {
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/user/active.aspx?id=" + id, true);
                    xhttp.send();
                });
                $(".change_level").on("change", function () {
                    document.getElementById("level").style.display = "block";
                    document.getElementById("confirm_id_user").innerHTML = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    document.getElementById("confirm_level_user").innerHTML = this.value;
                });
                $(".user_del").on("click", function () {
                    document.getElementById("del_id").innerHTML = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                });
                $(".user_edit").click(function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            document.getElementById("edit_user_modal").innerHTML = xhttp.responseText;
                            document.getElementById("edit_user_modal").style.display = "block";
                            $("#edit_txt_studentnumber").on("change", function () {
                                var number = document.getElementById("edit_txt_studentnumber").value;

                                var xhttp;
                                xhttp = new XMLHttpRequest();
                                xhttp.onreadystatechange = function () {
                                    if (xhttp.readyState == 4 || xhttp.status == 200) {
                                        document.getElementById("edit_check_number").innerHTML = xhttp.responseText;
                                        if (document.getElementById("edit_check_number").innerHTML.trim() == "1") {
                                            document.getElementById("edit_error_msg_number").style.display = "block";
                                        }
                                        if (document.getElementById("edit_check_number").innerHTML.trim() == "0" || number == "")
                                            document.getElementById("edit_error_msg_number").style.display = "none";
                                    }
                                };
                                xhttp.open("GET", "../ajax/asp/user/edit_check_number_study.aspx?number=" + number + "&id=" + id, true);
                                xhttp.send();
                            });
                            $("#edit_user").click(function () {
                                var number = document.getElementById("edit_txt_studentnumber").value;
                                var fullname = document.getElementById("edit_txt_fullname").value;
                                var day = document.getElementById("edit-reg-day").value;
                                var month = document.getElementById("edit-reg-month").value;
                                var year = document.getElementById("edit-reg-year").value;
                                var birthday = year + "-" + month + "-" + day;
                                var sex = "1";
                                if ($("#edit-reg-female").is(":checked")) {
                                    sex = "0"
                                }
                                var email = document.getElementById("edit_txt_user_email").value;
                                var phone = document.getElementById("edit_txt_user_phone").value;
                                var city = document.getElementById("edit_ddl_city").value;
                                var address = document.getElementById("edit_txt_address").value;

                                var check_username = document.getElementById("edit_check_username").innerHTML;
                                var check_number = document.getElementById("edit_check_number").innerHTML;

                                var x = document.getElementById("edit_error_msg");
                                if (number.trim() == "") {
                                    x.innerHTML = "Bạn chưa nhập mã học viên";
                                }
                                else {
                                    if (fullname.trim().length < 8)
                                        x.innerHTML = "Họ và tên phải lớn hơn 8 ký tự";
                                    else {
                                        if (email.trim().length == "") {
                                            x.innerHTML = "email không được để trống"
                                        }
                                        else {
                                            if (phone.trim().length < 10)
                                                x.innerHTML = "Số điện thoại phải tối thiểu 10 ký tự";
                                            else {
                                                if (city == "") {
                                                    x.innerHTML = "Bạn chưa chọn thành phố";
                                                }
                                                else {
                                                    if (address.trim() == "")
                                                        x.innerHTML = "Địa chỉ không được để trống";
                                                    else {
                                                        x.innerHTML = "";
                                                        if (check_number.trim() == "0" && check_username.trim() == "0") {
                                                            var xhttp;
                                                            xhttp = new XMLHttpRequest();
                                                            xhttp.onreadystatechange = function () {
                                                                if (xhttp.readyState == 4 || xhttp.status == 200) {
                                                                    location.reload(true);
                                                                }
                                                            };
                                                            xhttp.open("GET", "../ajax/asp/user/edited_user.aspx?id=" + id + "&number=" + number.trim() + "&fullname=" + fullname.trim() + "&email=" + email.trim() + "&phone=" + phone.trim() + "&city=" + city + "&address=" + address.trim() + "&birthday=" + birthday + "&sex=" + sex, true);
                                                            xhttp.send();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            });
                            $("#edit_ddl_province").on("change", function () {
                                var id = document.getElementById("edit_ddl_province").value;

                                var xhttp;
                                xhttp = new XMLHttpRequest();
                                xhttp.onreadystatechange = function () {
                                    if (xhttp.readyState == 4 || xhttp.status == 200) {
                                        document.getElementById("edit_ddl_city").innerHTML = xhttp.responseText;
                                    }
                                };
                                xhttp.open("GET", "../ajax/asp/staff/get_city.aspx?id=" + id, true);
                                xhttp.send();
                            });
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/user/edit_user.aspx?id=" + id, true);
                    xhttp.send();
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/user/find_by_level.aspx?id=" + id, true);
        xhttp.send();
    });

    $("#find_user_by_name").on("keyup", function () {
        var name = document.getElementById("find_user_by_name").value;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("user_show").innerHTML = xhttp.responseText;
                $(".on2").click(function () {
                    if ($(this).hasClass("off")) {
                        $(this).removeClass("off");
                        $(this).removeClass("fa-rotate-180");
                        $(this).removeClass("w3-text-red");
                        $(this).addClass("w3-text-teal");
                    }
                    else {
                        $(this).addClass("w3-text-red");
                        $(this).removeClass("w3-text-teal");
                        $(this).addClass("fa-rotate-180");
                        $(this).addClass("off");
                    }

                    var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 || xhttp.status == 200) {
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/user/active.aspx?id=" + id, true);
                    xhttp.send();
                });
                $(".change_level").on("change", function () {
                    document.getElementById("level").style.display = "block";
                    document.getElementById("confirm_id_user").innerHTML = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    document.getElementById("confirm_level_user").innerHTML = this.value;
                });
                $(".user_del").on("click", function () {
                    document.getElementById("del_id").innerHTML = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                });
                $(".user_edit").click(function () {
                    var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 && xhttp.status == 200) {
                            document.getElementById("edit_user_modal").innerHTML = xhttp.responseText;
                            document.getElementById("edit_user_modal").style.display = "block";
                            $("#edit_txt_studentnumber").on("change", function () {
                                var number = document.getElementById("edit_txt_studentnumber").value;

                                var xhttp;
                                xhttp = new XMLHttpRequest();
                                xhttp.onreadystatechange = function () {
                                    if (xhttp.readyState == 4 || xhttp.status == 200) {
                                        document.getElementById("edit_check_number").innerHTML = xhttp.responseText;
                                        if (document.getElementById("edit_check_number").innerHTML.trim() == "1") {
                                            document.getElementById("edit_error_msg_number").style.display = "block";
                                        }
                                        if (document.getElementById("edit_check_number").innerHTML.trim() == "0" || number == "")
                                            document.getElementById("edit_error_msg_number").style.display = "none";
                                    }
                                };
                                xhttp.open("GET", "../ajax/asp/user/edit_check_number_study.aspx?number=" + number + "&id=" + id, true);
                                xhttp.send();
                            });
                            $("#edit_user").click(function () {
                                var number = document.getElementById("edit_txt_studentnumber").value;
                                var fullname = document.getElementById("edit_txt_fullname").value;
                                var day = document.getElementById("edit-reg-day").value;
                                var month = document.getElementById("edit-reg-month").value;
                                var year = document.getElementById("edit-reg-year").value;
                                var birthday = year + "-" + month + "-" + day;
                                var sex = "1";
                                if ($("#edit-reg-female").is(":checked")) {
                                    sex = "0"
                                }
                                var email = document.getElementById("edit_txt_user_email").value;
                                var phone = document.getElementById("edit_txt_user_phone").value;
                                var city = document.getElementById("edit_ddl_city").value;
                                var address = document.getElementById("edit_txt_address").value;

                                var check_username = document.getElementById("edit_check_username").innerHTML;
                                var check_number = document.getElementById("edit_check_number").innerHTML;

                                var x = document.getElementById("edit_error_msg");
                                if (number.trim() == "") {
                                    x.innerHTML = "Bạn chưa nhập mã học viên";
                                }
                                else {
                                    if (fullname.trim().length < 8)
                                        x.innerHTML = "Họ và tên phải lớn hơn 8 ký tự";
                                    else {
                                        if (email.trim().length == "") {
                                            x.innerHTML = "email không được để trống"
                                        }
                                        else {
                                            if (phone.trim().length < 10)
                                                x.innerHTML = "Số điện thoại phải tối thiểu 10 ký tự";
                                            else {
                                                if (city == "") {
                                                    x.innerHTML = "Bạn chưa chọn thành phố";
                                                }
                                                else {
                                                    if (address.trim() == "")
                                                        x.innerHTML = "Địa chỉ không được để trống";
                                                    else {
                                                        x.innerHTML = "";
                                                        if (check_number.trim() == "0" && check_username.trim() == "0") {
                                                            var xhttp;
                                                            xhttp = new XMLHttpRequest();
                                                            xhttp.onreadystatechange = function () {
                                                                if (xhttp.readyState == 4 || xhttp.status == 200) {
                                                                    location.reload(true);
                                                                }
                                                            };
                                                            xhttp.open("GET", "../ajax/asp/user/edited_user.aspx?id=" + id + "&number=" + number.trim() + "&fullname=" + fullname.trim() + "&email=" + email.trim() + "&phone=" + phone.trim() + "&city=" + city + "&address=" + address.trim() + "&birthday=" + birthday + "&sex=" + sex, true);
                                                            xhttp.send();
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            });
                            $("#edit_ddl_province").on("change", function () {
                                var id = document.getElementById("edit_ddl_province").value;

                                var xhttp;
                                xhttp = new XMLHttpRequest();
                                xhttp.onreadystatechange = function () {
                                    if (xhttp.readyState == 4 || xhttp.status == 200) {
                                        document.getElementById("edit_ddl_city").innerHTML = xhttp.responseText;
                                    }
                                };
                                xhttp.open("GET", "../ajax/asp/staff/get_city.aspx?id=" + id, true);
                                xhttp.send();
                            });
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/user/edit_user.aspx?id=" + id, true);
                    xhttp.send();
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/user/find_by_name.aspx?name=" + name, true);
        xhttp.send();
    });

    $("#btn_level_add").on("click", function () {
        var level = document.getElementById("txt_level_add").value;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                location.reload(true);
            }
        };
        xhttp.open("GET", "../ajax/asp/user/add_level.aspx?level=" + level, true);
        xhttp.send();
    });

    $("#btn_level_edit").on("click", function () {
        document.getElementById("txt_level_edit").value = $("#find_by_level").find(":selected").text();
    });

    $("#btn_level_edited").on("click", function () {
        var id = document.getElementById("find_by_level").value;
        var name = document.getElementById("txt_level_edit").value;
        //alert(id + " " + name);

        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                location.reload(true);
            }
        };
        xhttp.open("GET", "../ajax/asp/user/edit_level.aspx?id=" + id + "&name=" + name, true);
        xhttp.send();
    });

    $("#btn_level_del").on("click", function () {
        var count = $(".user").length;
        if (count != 0) {
            alert("Không thể xóa quyền này khi vẫn còn Người dùng");
        } else {
            var id = document.getElementById("find_by_level").value;
            var xhttp;
            xhttp = new XMLHttpRequest();
            xhttp.onreadystatechange = function () {
                if (xhttp.readyState == 4 || xhttp.status == 200) {
                    location.reload(true);
                }
            };
            xhttp.open("GET", "../ajax/asp/user/del_level.aspx?id=" + id, true);
            xhttp.send();
        }
    });

    $("#sign-in-user").click(function () {
        var level = document.getElementById("find_by_level").value;
        var number = document.getElementById("txt_studentnumber").value;
        var username = document.getElementById("txt_user_username").value;
        var fullname = document.getElementById("txt_fullname").value;
        var day = document.getElementById("reg-day").value;
        var month = document.getElementById("reg-month").value;
        var year = document.getElementById("reg-year").value;
        var birthday = year + "-" + month + "-" + day;
        var sex = "1";
        if ($("#reg-female").is(":checked")) {
            sex = "0"
        }
        var email = document.getElementById("txt_user_email").value;
        var phone = document.getElementById("txt_user_phone").value;
        var city = document.getElementById("ddl_city").value;
        var address = document.getElementById("txt_address").value;

        var check_username = document.getElementById("check_username").innerHTML;
        var check_number = document.getElementById("check_number").innerHTML;

        var x = document.getElementById("error_msg");

        if (number.trim() == "") {
            x.innerHTML = "Bạn chưa nhập mã học viên";
        }
        else {
            if (username.trim() == "") {
                x.innerHTML = "Tên đăng nhập không được để trống";
            }
            else {
                if (username.trim().length < 6 || username.length > 21) {
                    x.innerHTML = "Tên đăng nhập phải từ 6 -> 20 ký tự";
                }
                else {
                    if (fullname.trim().length < 8)
                        x.innerHTML = "Họ và tên phải lớn hơn 8 ký tự";
                    else {
                        if (email.trim().length == "") {
                            x.innerHTML = "email không được để trống"
                        }
                        else {
                            if (phone.trim().length < 10)
                                x.innerHTML = "Số điện thoại phải tối thiểu 10 ký tự";
                            else {
                                if (city == "") {
                                    x.innerHTML = "Bạn chưa chọn thành phố";
                                }
                                else {
                                    if (address.trim() == "")
                                        x.innerHTML = "Địa chỉ không được để trống";
                                    else {
                                        x.innerHTML = "";
                                        if (check_number.trim() == "0" && check_username.trim() == "0") {
                                            var xhttp;
                                            xhttp = new XMLHttpRequest();
                                            xhttp.onreadystatechange = function () {
                                                if (xhttp.readyState == 4 || xhttp.status == 200) {
                                                    location.reload(true);
                                                }
                                            };
                                            xhttp.open("GET", "../ajax/asp/user/add_user.aspx?level=" + level + "&number=" + number.trim() + "&username=" + username.trim() + "&fullname=" + fullname.trim() + "&email=" + email.trim() + "&phone=" + phone.trim() + "&city=" + city + "&address=" + address.trim() + "&birthday=" + birthday + "&sex=" + sex, true);
                                            xhttp.send();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    });

    $("#ddl_province").on("change", function () {
        var id = document.getElementById("ddl_province").value;

        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("ddl_city").innerHTML = xhttp.responseText;
            }
        };
        xhttp.open("GET", "../ajax/asp/staff/get_city.aspx?id=" + id, true);
        xhttp.send();
    });

    $("#txt_studentnumber").on("change", function () {
        var number = document.getElementById("txt_studentnumber").value;
        number = number.trim();
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("check_number").innerHTML = xhttp.responseText;
                if (document.getElementById("check_number").innerHTML.trim() == "1") {
                    document.getElementById("error_msg_number").style.display = "block";
                }
                if (document.getElementById("check_number").innerHTML.trim() == "0" || number.trim() == "")
                    document.getElementById("error_msg_number").style.display = "none";
            }
        };
        xhttp.open("GET", "../ajax/asp/user/check_number_study.aspx?number=" + number.trim(), true);
        xhttp.send();
    });

    $("#txt_user_username").on("change", function () {
        var username = document.getElementById("txt_user_username").value;
        username = username.trim();
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 || xhttp.status == 200) {
                document.getElementById("check_username").innerHTML = xhttp.responseText;
                if (document.getElementById("check_username").innerHTML.trim() == "1") {
                    document.getElementById("error_msg_username").style.display = "block";
                }
                if (document.getElementById("check_username").innerHTML.trim() == "0")
                    document.getElementById("error_msg_username").style.display = "none";
            }
        };
        xhttp.open("GET", "../ajax/asp/user/check_username.aspx?username=" + username.trim(), true);
        xhttp.send();
    });

    $(".user_edit").click(function () {
        var id = this.parentElement.parentElement.getElementsByClassName("user_id")[0].innerHTML;
        var xhttp;
        xhttp = new XMLHttpRequest();
        xhttp.onreadystatechange = function () {
            if (xhttp.readyState == 4 && xhttp.status == 200) {
                document.getElementById("edit_user_modal").innerHTML = xhttp.responseText;
                document.getElementById("edit_user_modal").style.display = "block";
                $("#edit_txt_studentnumber").on("change", function () {
                    var number = document.getElementById("edit_txt_studentnumber").value;

                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 || xhttp.status == 200) {
                            document.getElementById("edit_check_number").innerHTML = xhttp.responseText;
                            if (document.getElementById("edit_check_number").innerHTML.trim() == "1") {
                                document.getElementById("edit_error_msg_number").style.display = "block";
                            }
                            if (document.getElementById("edit_check_number").innerHTML.trim() == "0" || number == "")
                                document.getElementById("edit_error_msg_number").style.display = "none";
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/user/edit_check_number_study.aspx?number=" + number + "&id=" + id, true);
                    xhttp.send();
                });
                $("#edit_user").click(function () {
                    var number = document.getElementById("edit_txt_studentnumber").value;
                    var fullname = document.getElementById("edit_txt_fullname").value;
                    var day = document.getElementById("edit-reg-day").value;
                    var month = document.getElementById("edit-reg-month").value;
                    var year = document.getElementById("edit-reg-year").value;
                    var birthday = year + "-" + month + "-" + day;
                    var sex = "1";
                    if ($("#edit-reg-female").is(":checked")) {
                        sex = "0"
                    }
                    var email = document.getElementById("edit_txt_user_email").value;
                    var phone = document.getElementById("edit_txt_user_phone").value;
                    var city = document.getElementById("edit_ddl_city").value;
                    var address = document.getElementById("edit_txt_address").value;

                    var check_username = document.getElementById("edit_check_username").innerHTML;
                    var check_number = document.getElementById("edit_check_number").innerHTML;

                    var x = document.getElementById("edit_error_msg");
                    if (number.trim() == "") {
                        x.innerHTML = "Bạn chưa nhập mã học viên";
                    }
                    else {
                        if (fullname.trim().length < 8)
                            x.innerHTML = "Họ và tên phải lớn hơn 8 ký tự";
                        else {
                            if (email.trim().length == "") {
                                x.innerHTML = "email không được để trống"
                            }
                            else {
                                if (phone.trim().length < 10)
                                    x.innerHTML = "Số điện thoại phải tối thiểu 10 ký tự";
                                else {
                                    if (city == "") {
                                        x.innerHTML = "Bạn chưa chọn thành phố";
                                    }
                                    else {
                                        if (address.trim() == "")
                                            x.innerHTML = "Địa chỉ không được để trống";
                                        else {
                                            x.innerHTML = "";
                                            if (check_number.trim() == "0" && check_username.trim() == "0") {
                                                var xhttp;
                                                xhttp = new XMLHttpRequest();
                                                xhttp.onreadystatechange = function () {
                                                    if (xhttp.readyState == 4 || xhttp.status == 200) {
                                                        location.reload(true);
                                                    }
                                                };
                                                xhttp.open("GET", "../ajax/asp/user/edited_user.aspx?id="+id+"&number=" + number.trim() + "&fullname=" + fullname.trim() + "&email=" + email.trim() + "&phone=" + phone.trim() + "&city=" + city + "&address=" + address.trim() + "&birthday=" + birthday + "&sex=" + sex, true);
                                                xhttp.send();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                });
                $("#edit_ddl_province").on("change", function () {
                    var id = document.getElementById("edit_ddl_province").value;

                    var xhttp;
                    xhttp = new XMLHttpRequest();
                    xhttp.onreadystatechange = function () {
                        if (xhttp.readyState == 4 || xhttp.status == 200) {
                            document.getElementById("edit_ddl_city").innerHTML = xhttp.responseText;
                        }
                    };
                    xhttp.open("GET", "../ajax/asp/staff/get_city.aspx?id=" + id, true);
                    xhttp.send();
                });
            }
        };
        xhttp.open("GET", "../ajax/asp/user/edit_user.aspx?id=" + id, true);
        xhttp.send();
    });

});